﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient; // Connect to Database
using System.Net.Mail; // Send feedback form to email
using System.Net;
using System.Web.Security;
using System.Xml.Linq;
using System.Data.Common;

public partial class LeadershipBoard : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Added by CL
        if (!HttpContext.Current.Request.IsAuthenticated)
        {
            Response.Redirect("~/login.aspx");
        }
        else
        {
            if ((string)Session["GameID"] == "-1")
                Response.Redirect("~/GameMode.aspx");

            else
            {
                GetMaketValue((string)Session["GameID"]);
            }
        }
    }

    public void GetMaketValue(string GameID)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["stockmarketConnectionString"].ConnectionString;
        SqlCommand mySqlCommand = new SqlCommand();
        SqlConnection mySqlConnection = new SqlConnection(connectionString);
        SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
        DataSet myDataSet = new DataSet();       

        mySqlCommand = mySqlConnection.CreateCommand();
        mySqlCommand.CommandText = "GetMarketValue";
        mySqlCommand.Parameters.AddWithValue("@GameID", GameID);
        mySqlCommand.CommandType = CommandType.StoredProcedure;

   
        mySqlDataAdapter.SelectCommand = mySqlCommand;

        
        mySqlConnection.Open();

        mySqlDataAdapter.Fill(myDataSet, "MaketValue");

        mySqlConnection.Close();

        GridViewLeadershipBoard.DataSource = myDataSet;
        GridViewLeadershipBoard.DataBind();
    }
}